/**
 * 
 */
package com.lorizz.picpub.web.controller.impl;

import org.springframework.validation.Errors;

/**
 * @author wind hong
 *
 */
public class ValidatorUtils {
    
    public static void NotNull(String field, Object value, Errors errors, String code) {
        if (value == null)
            errors.rejectValue(field, code);
    }
    
    public static void NotEmpty(String field, Object value, Errors errors, String code) {
        NotNull(field, value, errors, code);
        if (value instanceof String) {
            if (((String) value).length() == 0)
                errors.rejectValue(field, code);
        }
    }

}
